package com.dhsc.service.impl.wskh;

import com.dhsc.domain.ywzx.wskh.KhsxjlVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.wskh.IKhsxjlcxDao;
import com.dhsc.service.wskh.IKhsxjlcxService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 客户失信记录信息
 * @date 2025/4/17 10:29
 */
@Service
@Slf4j
public class KhsxjlcxServiceImpl implements IKhsxjlcxService {

    @Autowired
    private IKhsxjlcxDao khsxjlcxDao;
    @Override
    public LayuiTableVo queryKhsxjlxx(KhsxjlVo k) {
        LayuiTableVo obj = new LayuiTableVo();
        try{
            PageMethod.startPage(k.getPage(),k.getLimit());
            List<KhsxjlVo> list = khsxjlcxDao.queryKhsxjlxx(k);
            PageInfo<KhsxjlVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch(Exception e){
            log.error("查询客户失信记录信息出错", e);
            throw new MyException("查询客户失信记录信息出错",e);
        }
        return obj;
    }

    @Override
    public LayuiTableVo queryJlmx(KhsxjlVo k) {
        LayuiTableVo obj = new LayuiTableVo();
        try{
            PageMethod.startPage(k.getPage(),k.getLimit());
            List<KhsxjlVo> list = khsxjlcxDao.queryJlmx(k);
            PageInfo<KhsxjlVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setMsg("");
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
        }catch(Exception e){
            log.error("查询记录明细出错", e);
            throw new MyException("查询记录明细出错",e);
        }
        return obj;
    }
}
